package com.headwire.kw.helpers;

import java.io.*;

public class FileLineTransformer
{
	private BufferedReader in;
	private PrintWriter out;
	public FileLineTransformer(String inFile, String outFile) {
		try {
			in = new BufferedReader(new FileReader(inFile));
			out = new PrintWriter(new FileWriter(outFile));
		} catch(Exception e) {
			throw new RuntimeException("You failed, file doesn't exist");
		}
	}
	
	public void doTransform() {
		try {
			String cur;
			while((cur = in.readLine())!=null) {
				out.println(transformLine(cur));
			}
			out.close();
			in.close();
		} catch(Exception e) {
			throw new RuntimeException("Transform failed",e);
		}
	}
	
	// Either extend FileLineTransformer and override this or use codeholder
	public String transformLine(String line) {
		return CodeHolder.transformLine(line);
	}
}